//
//  SNShopNoticesListModel.m
//  app
//
//  Created by 王少宁 on 15/8/20.
//  Copyright (c) 2015年 hdaren. All rights reserved.
//

#import "SNShopNoticesListModel.h"

@implementation SNShopNoticesListModel

- (instancetype)initWithArray:(NSArray *)array
{
    if ([super initWithArray:array]) {
        
        _more = NO;
        
        if (array && array.count) {

            NSMutableArray * mutableArray = [NSMutableArray array];
            for (NSDictionary * dic in array) {
                SNShopNoticesListSubModel * model = [SNShopNoticesListSubModel modelWithDict:dic];
                [mutableArray addObject:model];
            }
            _notices_listArray = mutableArray;
            
            if (array.count <= 3) {
                self.rowNumber = array.count;
            } else {
                self.rowNumber = 3;
                _more = YES;
            }
            
            self.cellHeight = SCREEN_WIDTH * 160/720;
            self.headerView = YES;
            self.headerTitle = @"最新公告";
        }
    }
    return self;
}

@end








@implementation SNShopNoticesListSubModel

- (instancetype)initWithDict:(NSDictionary *)dict
{
    if ([super init]) {
        _iD = [dict[@"id"] stringValue];
        _isTop = [dict[@"isTop"] boolValue];
        _typeName = dict[@"typeName"];
        _title = dict[@"title"];
        _title_pic = dict[@"title_pic"];
        _intros = dict[@"intros"];
        _views = [dict[@"views"] stringValue];
        _url = dict[@"url"];
        _createtime = [dict[@"createtime"] stringValue];
    }
    return self;
}

+ (instancetype)modelWithDict:(NSDictionary *)dict
{
    return [[self alloc] initWithDict:dict];
}

@end